package retrofitdemo.com.night.utils;

import com.google.gson.Gson;
import com.lzy.okgo.callback.StringCallback;

import retrofitdemo.com.night.bean.ApiService;

import static com.lzy.okgo.OkGo.get;
import static com.lzy.okgo.OkGo.post;

/**
 * Created by 86178 on 2020/3/11.
 * author mogen
 * 用心，成就一切。
 */
public class HTTPAPI {

    public static HTTPAPI instance;

    private static Gson gson = null;

    public static HTTPAPI getInstance() {
        if (instance == null) {
            instance = new HTTPAPI();
        }
        if (gson == null) {
            gson = new Gson();
        }
        return instance;
    }


//                .upJson(gson.toJson(bean))
//                .headers("type", "2")


    /**
     * 获取博物馆楼层
     * @param callback
     */
    public void getBWGFloors(StringCallback callback){
        post( ApiService.GET_BWG_FLOORS)
                .tag(this)
                .connTimeOut(30000)
                .execute(callback);
    }


    /**
     * 获取博物馆详情
     * @param callback
     */
    public void getBWGDesc(StringCallback callback){
        post( ApiService.BWG_DESC)
                .tag(this)
                .connTimeOut(30000)
                .execute(callback);
    }


    /**
     * 获取楼层多图片
     * @param id
     * @param callback
     */
    public void getFloorMoreImage(String id,StringCallback callback){
        get( ApiService.BWG_MORE_IMG )
                .tag(this)
                .connTimeOut(30000)
                .params( "lid",id )
                .execute(callback);
    }

    /**
     * 获取图片详情
     * @param id
     * @param callback
     */
    public void getFloorMoreImageDesc(String id,StringCallback callback){
        get( ApiService.BWG_IMG_DESC )
                .tag(this)
                .connTimeOut(30000)
                .params( "id",id )
                .execute(callback);
    }

    /**
     * 获取博物馆活动
     * @param callback
     */
    public void getBWGClass(StringCallback callback){
        get( ApiService.FLOOR_CLASS )
                .tag(this)
                .connTimeOut(30000)
                .execute(callback);
    }

}
